#-------------------------------------------------------------------------------
# Name:        module1
# Purpose:
#
# Author:      Pablo
#
# Created:     13/06/2012
# Copyright:   (c) Monxcleyr Productions 2012
# Licence:     GPL v3
#-------------------------------------------------------------------------------
#!/usr/bin/env python

import os, settings, config, key
from ..tools import videotools

class Common():

  """Common class stores commonly used engine variables. This class can be passed as an
  argument to other classes instead of sending over multiple variables or importing larger
  classes. """

  def __init__(self):

    self.settings = settings.settings('Settings/settings.ini')
    self.settings.load()
    self.load()
    # Classes for window scaling
    self.videoresize = videotools.Resize((self.initsize))
    self.videomouse = videotools.Mouse((self.initsize))
    self.key = key.Keys()
    self.time = 0


  def load(self):

    #---------------------------- Load Engine Config -------------------------------

    engineconf = config.Config()
    engineconf.read(os.path.join('resources/configs/engine.ini'))
    self.name = engineconf.get('General', 'name')
    self.version = engineconf.get('General', 'version')
    self.buffersize = engineconf.getint('Sounds', 'buffersize')
    self.caption = engineconf.get('General', 'caption')
    self.initsize = engineconf.getint_tuple('Graphics', 'defaultres')
    self.smallest = engineconf.getint('Graphics', 'smallestwidth')
    self.reswidths = engineconf.getint_list('Graphics', 'reswidths')
    self.mapchunksize = engineconf.getint('Graphics', 'mapchunksize')
    self.scale = float(self.initsize[0]) / float(self.initsize[1])
